package base.iterator.array;

public class BookShelfIterator implements Iterator {

    private BookShelf bookshelf;
    private int index;

    public BookShelfIterator(BookShelf bookShelf) {
        this.bookshelf = bookShelf;
        this.index = 0;
    }

    @Override
    public boolean hasNext() {
        if (this.index < bookshelf.getLength()) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Object next() {
        Book book = bookshelf.getBook(index);
        index++;
        return book;
    }

}
